/*
 * @Author: Creator
 * @Date: 2020-10-09 14:11:40
 * @LastEditors: Creator
 * @LastEditTime: 2020-10-09 14:31:48
 * @Description: file content
 */
#ifndef MEDICINE_H_INCLUDED
#define MEDICINE_H_INCLUDED
#include<stdio.h>
typedef struct Medicine
{
    int usedAmount[30];
    int perSumPrice;
}medicine;
float medicinePrice[30]={30.51,10.42,23.40,32.87,98.07,
                        34.00,55.12,99.09,123.45,25.17,
                        34.25,50.76,23.98,200.99,87.64,
                        439.89,42.18,35.96,39.12,18.29,
                        89.82,999.99,333.42,27.98,38.92,
                        63.89,45.56,761.32,309.81,69.96};
char medicineName[30][20]={"去乙酰\0","阿替洛尔\0","美西律\0","硝苯地平\0",
                        "卡托普利\0","氢氧化铝\0","盐酸硝檗碱\0","炎痛喜康\0","双氯芬酸\0",
                        "叶绿醌\0","可待因\0","曲安奈德\0","地塞米松\0","生理盐水\0","三磷酸腺苷\0",
                        "核黄素\0","高锰酸钾粉\0","利巴韦林\0","头孢氨苄\0","头孢乙氰\0","米诺环素\0",
                        "葡醛内酯\0","依托泊苷\0","氟尿嘧啶\0","西地那非\0","乐安定\0","苯海索\0",
                        "甲基睾丸素\0","肾必安\0","安宫黄体酮\0"};
void initialMedicine(medicine a1)
{
    int i;
    for(i=0;i<30;i++)
        a1.usedAmount[i]=0;
        a1.perSumPrice=0;
}
void inputMedicine(medicine a1)
{
    int a,b;
    int input[60];
    printf("请输入该患者所需的药品编号：\n");
    printf("(输入-1表示结束)\n");
    scanf("%d",&a);


    while(a!=-1)
    {
        printf("请输入该药品所需要数量：\n");
        scanf("%d",&b);
        if(b!=-1)
          a1.usedAmount[a-1]=b;
          else return;
          scanf("%d",&a);
    }
    return ;
}
int culculateSumPrice(medicine a1)
{
    int i;
    for(i=0;i<30;i++)
        a1.perSumPrice=a1.perSumPrice+a1.usedAmount[i]*medicinePrice[i];
    return a1.perSumPrice;
}
void convertName(int i)//我直接打印药名，因为转换函数就是为了打印
{
    int j;
    for(j=0;j<10&&medicineName[i][j]!='\0';j++)
        printf("%c",medicineName[i][j]);
}
void printMedicine(medicine a1)
{
    int i,j;
    printf("该患者使用药物共花费%d元！\n",a1.perSumPrice);
    printf("该患者具体购买药物信息如下：\n");
    for(i=0;i<30;i++)
        if(a1.usedAmount[i]!=0)
    {
        printf("购买了");
        convertName(i);
        printf("共%d盒!\n",a1.usedAmount[i]);
    }
}

#endif